<?php
/**
 * @author : xjw129xjt 531201650@qq.com
 */

namespace app\forum\model;

use think\Model;

class ForumPost extends Model
{
    protected $table = 'forum_post';

    public function getPost($id)
    {
        $detail = $this->where('id', $id)->find();
        return $detail;
    }

    public function getPostListByBid($bid)
    {
        $list = $this->where('bid', $bid)->where('status', 1)->order('update_time desc , id desc')->select();
        return $list;
    }

    public function addPost($data)
    {
        empty($data['status']) && $data['status'] = 1;
        empty($data['create_time']) && $data['create_time'] = time();
        empty($data['update_time']) && $data['update_time'] = time();
        $id = $this->insertGetId($data);
        return $id;
    }

}

